using System;
using System.Data;

using Common;

namespace Core
{
    public class ColumnInfo
    {
        public DataRow Properties = null;

        public string Name = null;
        public string RealDB_Type = null;
        public string System_Type = null;

        public bool AllowDBNULL;
        public bool IsIdentity;
        public bool IsReadOnly;
        public bool IsKey;

        public TableInfo Table;

        public ColumnInfo(DataRow column, TableInfo tableInfo)
        {
            this.Table = tableInfo;

            this.Properties = column;

            this.Name = column[ColumnPropName.ColumnName].ToString();
            this.AllowDBNULL = Convert.ToBoolean(column[ColumnPropName.AllowDBNULL]);
            this.RealDB_Type = column[ColumnPropName.DataBase_Type].ToString();
            this.System_Type = column[ColumnPropName.System_Type].ToString();

            this.IsIdentity = Convert.ToBoolean(column[ColumnPropName.IsIdentity]);
            this.IsReadOnly = Convert.ToBoolean(column[ColumnPropName.IsReadOnly]);
            this.IsKey = column[ColumnPropName.IsKey] is System.DBNull ? false : Convert.ToBoolean(column[ColumnPropName.IsKey]);
        }
    }
}